package com.project.controller;

import com.project.pojo.Goods;
import com.project.service.GoodsService;
import com.project.utils.ResponseData;
import com.project.utils.ResponseDataUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    public GoodsService goodsService;

//    @GetMapping("/{id}")
//    public List<Goods> goodslist(@PathVariable("id") Integer id){
//        List<Goods> goodsList = goodsService.queryAllGoods(id);
//        return goodsList;
//    }

    @GetMapping("/{id}")
    public ResponseData<Goods> goodslist(@PathVariable("id") Integer id){
        List<Goods> goodsList = goodsService.queryAllGoods(id);
        return ResponseDataUtil.buildOk(goodsList);
    }

    @GetMapping("/allgoods")
    public ResponseData<Goods> goodsList(){
        List<Goods> goodsLists=goodsService.selectAllGoods();
        return ResponseDataUtil.buildOk(goodsLists);
    }
}
